package com.ruoyi.mall.front.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.mall.front.service.FrontLoginService;
import com.ruoyi.mall.front.vo.MallMembersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName FrontLoginController
 * @Description: 前端登录控制器
 * @Author cjc
 * @Date 2020/5/15
 * @Version V1.0
 **/
@RestController
@RequestMapping("mall/front")
public class FrontLoginController extends BaseController {
    /**
     * 前端登录业务
     */
    @Autowired
    private FrontLoginService frontLoginService;
    @PostMapping("login")
    public AjaxResult login(@RequestBody MallMembersVo mallMembersVo){
        if (null == mallMembersVo.getPhone() || "".equals(mallMembersVo.getPhone())){
            return AjaxResult.error("手机号不能为空！");
        }
        if (null == mallMembersVo.getPassword()|| "".equals(mallMembersVo.getPassword())){
            return AjaxResult.error("密码不能为空！");
        }
//        if (null == mallMembersVo.getCaptcha()|| "".equals(mallMembersVo.getCaptcha())){
//            return AjaxResult.error("验证码不能为空！");
//        }
        return frontLoginService.login(mallMembersVo);
    }
}
